#include<bits/stdc++.h>
using namespace std;
#define rd(i,n) for(int i=0;i<n;i++)
#define rp(i,n) for(int i=1;i<=n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef unsigned long long ull;
const int N=100005;
int n,m,v[N],d[N],a[N],p[N],L,V,l[N],r[N],usd[N];
int q[N],hd,ed,dp[N],bd[N];
inline void solve(){
    cin>>n>>m>>L>>V;
    rp(i,n)cin>>d[i]>>v[i]>>a[i];
    rp(i,m)cin>>p[i];
    rp(i,m+1)bd[i]=0,dp[i]=0;
    rp(i,n){
        l[i]=d[i],r[i]=L,usd[i]=1;
        if(a[i]==0){
            if(v[i]<=V)usd[i]=0;
        }else if(a[i]<0){
            if(v[i]<=V)usd[i]=0;
            else{
                int t=d[i]+(v[i]*v[i]-V*V-2*a[i]-1)/(-2*a[i])-1;
                r[i]=min(r[i],t);
            }
        }else if(a[i]>0){
            if(v[i]<=V){
                int t=d[i]+(V*V-v[i]*v[i])/(2*a[i])+1;
                l[i]=max(l[i],t);
            }
        }
    }
    int cnt=0;
    rp(i,n)if(usd[i]){
        l[i]=lower_bound(p+1,p+1+m,l[i])-p;
        r[i]=upper_bound(p+1,p+1+m,r[i])-p-1;
        if(l[i]<=r[i])cnt++,bd[r[i]+1]=max(bd[r[i]+1],l[i]);
    }
    dp[0]=0,q[hd=ed=1]=0;
    rep(i,1,m+1){
        while(q[hd]<bd[i])hd++;
        dp[i]=dp[q[hd]]+1;
        while(hd<=ed&&dp[q[ed]]>dp[i])ed--;
        q[++ed]=i;
    }
    cout<<cnt<<' '<<m-dp[m+1]+1<<'\n';
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t;
    cin>>t;
    rd(_,t)solve();
    return 0;
}
//g++ detect.cpp -o detect -O2 -std=c++14 -static
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
